home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
3D GFX
/
3D GFX.iso
/
pcutils
/
windows
/
genesis
/
include
/
tool.h
< prev
Wrap
C/C++ Source or Header
|
1995-12-30
|
9KB
|
183 lines
/*------------------------------------------------------------------
Tool Include
------------
This is the main tool include file. Any tool DLLs should
include this file as it contains the interface for the
tool base class from which all tools are derived. It
also provides the prototypes for the main DLL entry points
used to create and delete the tool object (NB. The editor
code cannot create a derived class it doesn't know about)
(C) Silicon Dream Ltd 1994
------------------------------------------------------------------
Changes: Date:
* Created file 27/12/94
*/
#ifndef TOOL
#define TOOL
#define STRICT // For correct HDC definition, otherwise derived tools get linker error
#include <windows.h>
#include <atomic.h>
#include <cppmaths.h>
#include <cppdebug.h>
#include <geometry.h>
/* Used by tool to inform editor what to redraw after a tool action */
typedef enum Redraw{REDRAW_ALL=0, // Re-renders and redraws overlay
REDRAW_NONE, // No redraw
REDRAW_TOOL, // Redraw ONLY using tools DrawSoFar() routine
REDRAW_NOTOOL, // Refreshes screen from bitmaps and thats all
REDRAW_REFRESH, // Refreshes screen from bitmaps and calls DrawSoFar()
REDRAW_OBJECT_WIRE, // Redraw current object only direct to screen in XOR
PRIVATE_REDRAW_OVERLAY}; // Reserved
/* Tool callback codes and router function definition */
#define CT_WRITEMESSAGE 0
#define CT_SETVIEWDATA 1
#define CT_ADDNAMEDOBJ 2
#define CT_ADDNAMEDCSYS 3
#define CT_DELNAMEDOBJ 4
#define CT_DELNAMEDCSYS 5
#define CT_GETSELOBJECTS 6
#define CT_GETOBJHANDLE 7
#define CT_GETCSYSHANDLE 8
#define CT_GETOBJNAME 9
#define CT_GETCSYSNAME 10
#define CT_UPDATEVIEWS 11
#define CT_ACTIVATECSYSWIN 12
#define CT_GETCURRENTSURF 13
typedef ulong _exp fnToolCallback(void *pvDoc, ushort usCallType,
ulong ul1, ulong ul2, ulong ul3);
/* Marker types */
#define MT_BOX 0
#define MT_PLUS 1
#define MT_CROSS 2
#define MT_DIAMOND 3
/* Flags for DrawArrow */
#define DA_FILLED 1
#define DA_FIXEDSIZE 2
/* Maximum list object name length */
#define MAX_NAME_BUFF_LEN 35 // To allow for null and digits
#define MAX_NAME_LEN 30
/* Notice all the functions in the Tool class are virtual as it serves
purely as a polymorphic interface for derived classes. The functions
implemented in the Tool class do nothing. We cannot however make them
pure virtual as we would then have an abstract class, and derived tools
would be required to implement every function otherwise they too would
become abstract classes (ie. we wouldn't be able to create one) */
class Tool
{
private:
void *pvDoc; // Ptr to document object
fnToolCallback *ToolCallback; // Callback entry point to editor
ulong ulMaxVerts, ulMaxNorms, ulMaxPats;
HanObject hobjPrim;
bool bReportErrs, bUndoOnErr;
public:
HINSTANCE hinst; // Instance of DLL
HWND hwnd; // Main frame window
HanVertex *ahverPrim, hverPrim; // Primitive vertex handle array
HanNormal *ahnorPrim, hnorPrim; // Primitive normal handle array
HanPatch *ahpatPrim; // Primitive patch handle array
ulong ulNumVerts, ulNumNorms, ulNumPats; // Numbers of elements
HanCoorSys hcsysTopLevel; // Documents top level coor sys
HanCoorSys hcsysOnSelect; // Active coor sys when tool selected
HanSurf hsurOnSelect; // Current surface when tool selected
public:
// Overideables
virtual _cppdyn ~Tool(); // Destructor
virtual void _cppdyn Initialise(); // Called once when DLL loaded
virtual Redraw _cppdyn OnSelect(Vec &vec); // Called when tool is selected
virtual Redraw _cppdyn OnUnSelect(bool *pbOkToChange); // Called when tool is selected
virtual void _cppdyn OnConfigure(); // Called to configure tool
virtual Redraw _cppdyn OnButtonDown(Vec &vec); // Called when button pressed
virtual Redraw _cppdyn OnMouseMove(Vec &vec); // Called when mouse moves with button down
virtual Redraw _cppdyn OnButtonUp(Vec &vec); // Called when button is released
virtual Redraw _cppdyn OnSet(Vec &vec); // Called when the 'Set' button is clicked
virtual Redraw _cppdyn OnUndo(); // Called when user wishes to undo effect of tool
virtual Redraw _cppdyn OnDo(Vec &vec); // Called to end use of tool
virtual void _cppdyn OnViewChange(HanCoorSys hcsys, Vec &vec); // Called when active view changes
virtual void _cppdyn DrawSoFar(HDC hdc, HanCoorSys hcsys,
void *pvViewData, bool bInvalid); // Called to draw object so far into the view
// Tool support functions
void _cppdyn WriteMessage(int iResId); // Call to write message in status bar
void _cppdyn WriteMessage(const char *szMsg); // Call to write message in status bar
int _cppdyn MessageBox(int iTitleId, int iMsgId, UINT uiStyle=MB_ICONEXCLAMATION); // Call to create message box
int _cppdyn MessageBox(int iTitleId, const char *szMsg, UINT uiStyle=MB_ICONEXCLAMATION); // Call to create message box
int _cppdyn MessageBox(int iTitleId, GeomErr gerr); // Call to create message box
void _cppdyn EndPrim (void); // Removes buffers for handles
bool _cppdyn StartPrim (HanObject hobj, ulong ulMaxVerts, // Allocate buffers for handles
ulong ulMaxNorms, ulong ulMaxPats,
bool bReportErrs, bool bUndoOnErr);
void _cppdyn RemovePrim (void); // Removes all primitive elements (verts etc.)
GeomErr _cppdyn AddVertex (Vec &vec); // Adds a vertex (records handle)
GeomErr _cppdyn AddNormal (Vec &vec); // Adds a normal (records handle)
GeomErr _cppdyn DefPatch (ushort usNumEdges, ushort usFlags, float fSmoothAng, // Adds a patch (records handle)
HanVertex *ahver, HanNormal *ahnor, HanSurf hsur=NULL_HANDLE);
HanObject _cppdyn AddObject(HanCoorSys hcsys, char *szName, // Adds a new named object
ushort usBuffSize, float fNewVertTol, HanObject hobj);
HanCoorSys _cppdyn AddCoorSys(HanCoorSys hcsysParent, char *szName, // Adds a new named coor sys
ushort usBuffSize, HanCoorSys hcsys,
Mat &matToParent, Mat &matFromParent,
ushort usType, bool bAddView);
bool _cppdyn DelObject(const char *szName); // Removes a named object
bool _cppdyn DelCoorSys(const char *szName); // Removes a named coor sys
ushort _cppdyn GetSelectedObjects(char *szNames, ushort usBuffSize); // Returns names of selected objects
HanObject _cppdyn GetObjectHandle(const char *szName);// Returns the handle of a named object
HanCoorSys _cppdyn GetCoorSysHandle(const char *szName);// Returns the handle of a named coor sys
void _cppdyn GetObjectName(HanObject hobj, char *szName, // Returns the name of the object with the handle
ushort usBuffSize);
void _cppdyn GetCoorSysName(HanCoorSys hcsys, char *szName, // Returns the name of the coor sys with the handle
ushort usBuffSize);
void _cppdyn DrawMarker(HDC hdc, int iX, int iY, ushort usType); // Draws a marker on the DC
void _cppdyn DrawArrow(HDC hdc, int iX, int iY, ushort usFlags); // Draws an arrow onto the DC
void _cppdyn SetViewData(void *pvData, ushort usSize); // Sets data for all views
void _cppdyn BackgroundYield(const char *szWrite=NULL);// Yields control and writes message
void _cppdyn ForceRedraw(Redraw rd, HanCoorSys hcsys=NULL_HANDLE); // Forces a redraw independently of event
bool _cppdyn ActivateCSysWin(HanCoorSys hcsys); // Activates coor sys window (brings to top)
HanSurf _cppdyn GetCurrentSurf(); // Returns handle to currently selected surface
void _cppdyn ModifiedScene(); // Mark scene as modified by this tool
// Editor support functions (not for use by derived tools)
void _cppdyn Initialise(HINSTANCE hinstDLL,
void *pvDocIn,
HWND hwnd,
fnToolCallback *ToolCallbackIn,
HanCoorSys hcsysDocTop); // Called to initialise base class
Redraw _cppdyn OnSelect(HanCoorSys hcsysActive, HanSurf hsurCurrent,
Vec &vec); // Called to initialise tools public data
};
/* The IMPLEMENT_OBJECT macro implements the CreateTool and DeleteTool functions, and the
typedefs are used by the editor to call the function */
#define IMPLEMENT_OBJECT(class) _st class tool; extern "C" { \
Tool *_getdyn CreateTool() {return New class;} \
void _getdyn DeleteTool(Tool *ptool) {Delete ptool;}}
typedef Tool *_getdyn fnCreateTool();
typedef void _getdyn fnDeleteTool(Tool *ptool);
#endif